- /* slfctout.cpp by K.Tsuru */
- // function ID = 222 DRADIX, BRADIX
- /******************************************************************************
- SLong and SInteger classes
- It cuts out a "size" part from "src[pos]" and puts into dest[0]...dest[size-1].
- The sign is the same as that of "src".
- src[pos]....src[pos+size-1]
- If pos+size-1 < src.aTail it sets zero.
- *******************************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- void SLong::SLCutOut(SLong& dest, const SLong& src, uint pos, uint size){
- dest.SetType(src.Type());
- if( (src.Sign(222) == 0) || (pos > src.Head() ) || (pos+size < src.Tail()+1u) ){
- dest.SetZero(); return;
- }
- uint n_copy = min(size, src.figure.size() - pos);
-
- dest.valloc(n_copy, -1);
- fType* df = dest.figure.Elements();
-
- memcpy(df, src.ReadFigures()+pos, n_copy*sizeof(fType) );
- dest.figure.clear(n_copy);
- /*
- It gets the figure positions. It must be noticed that there are many zeros
- in the middle region such as
- p+s-1 p
- src = 0000 0000 5000 0000 0000 0000 .... 0000 0000 1234 5678 ....
- */
- int j = 0;
- while( (df[j] == 0) && (j < (int)n_copy)) j++;
- if(j == (int)n_copy){
- dest.SetSign(0); return;
- }
- dest.aTail = (uint)j;
-
- #ifndef NDEBUG
- assert( (uint)j < n_copy);
- #endif
- j = (int)n_copy-1;
- while(df[j] == 0) j--;
- dest.aHead = (uint)j;
- #ifndef NDEBUG
- assert(j >= 0);
- #endif
- dest.SetSign(src.Sign()); // dest != 0
- }
slfctout.cpp : last modifiled at 2017/03/13 14:32:00(1,474 bytes)
created at 2017/10/07 10:26:50
The creation time of this html file is 2017/11/09 14:52:03 (Thu Nov 09 14:52:03 2017).